import { Controller } from "../../mvc/core/Controller";
import { Dispatcher } from "../../mvc/core/Dispatcher";
import { EventName } from "../mvc/EventName";
import { PetEventName } from "../view/pet/PetEventName";
import { GModuleEvent } from "../mvc/GModuleEvent";
import { NetDispatcher } from "../../mvc/core/NetDispatcher";
import { ServerCommand } from "../mvc/ServerCommand";
import { EGateCommand } from "../../../Message/Command/EGateCommand";
import { DataEvent } from "../events/DataEvent";
import { SPetBlood } from "../../../Message/Game/SPetBlood";
import { PetSkillUpgradeOperateVo } from "../view/pet/vo/PetSkillUpgradeOperateVo";
import { GameProxy } from "../mvc/GameProxy";
import { MessageBlock } from "../../../Framework/MQ/MessageBlock";
import { SPetSpecialSkillInfo } from "../../../Message/Game/SPetSpecialSkillInfo";
import { IView } from "../../mvc/interfaces/IView";
import { PetModule } from "../../../modules/PetModule";
import { WindowEvent } from "../../component/window/WindowEvent";
import { IPetModule } from "../../../modules/interfaces/IPetModule";
import { PetUtil } from "../view/pet/info/PetUtil";
import { SPetBag } from "../../../Message/Game/SPetBag";
import { SPetUpdate } from "../../../Message/Game/SPetUpdate";
import { EPlayerItemPosType } from "../../../Message/Public/EPlayerItemPosType";
import { PetColor } from "../view/pet/info/PetColor";
import { MsgManager } from "../manager/MsgManager";
import { Language } from "../../../extend/language/Language";
import { PetAddWindow } from "../view/pet/PetAddWindow";
import { SPetInfo } from "../../../Message/Game/SPetInfo";
import { PetIlluEventName } from "../view/pet/illu/PetIlluEventName";
import { EPetStatus } from "../../../Message/Game/EPetStatus";
import { GameMapUtil } from "../scene/map/GameMapUtil";
import { ScreenOperation } from "../scene/ScreenOperation";
import { AutoFight } from "../view/autoFight/AutoFight";
import { GameController } from "../mvc/GameController";
import { Cache } from "../cache/Cache";
import { PetCoolDownInfo } from "../view/pet/PetCoolDownInfo";
import { SoundManager } from "../../common/sound/SoundManager";
import { SoundTypeConst } from "../../common/sound/SoundTypeConst";
import { SPetStatusUpdate } from "../../../Message/Game/SPetStatusUpdate";
import { FeedType } from "../view/pet/FeedType";
import { PetDrugEffect } from "../view/pet/PetDrugEffect";
import { GuideArrowManager } from "../manager/GuideArrowManager";
import { Alert } from "../../../com/mui/controls/Alert";
import { ShopRule } from "../rules/ShopRule";
import { AIManager } from "../scene/ai/AIManager";
import { ItemData } from "../resource/info/ItemData";
import { SEntityId } from "../../../Message/Public/SEntityId";
import { PetViewWindow } from "../view/pet/PetViewWindow";
import { PetSkillRefreshWindow } from "../view/pet/skill/PetSkillRefreshWindow";
import { BatchRefreshWindow } from "../view/pet/skill/BatchRefreshWindow";
import { SPetSkill } from "../../../Message/Game/SPetSkill";
import { PetSkillForgetWindow } from "../view/pet/skill/PetSkillForgetWindow";
import { PetSkillHelpWindow } from "../view/pet/skill/PetSkillHelpWindow";
import { PetLifespanWindow } from "../view/pet/addLifespan/PetLifespanWindow";
import { SRandPetSkillActive } from "../../../Message/Game/SRandPetSkillActive";
import { ItemsUtil } from "../view/shortcuts/item/ItemsUtil";
import { EPetEquipRepairType } from "../../../Message/Game/EPetEquipRepairType";
import { PulseSharedObject } from "../view/player/PulseSharedObject";
import { TodayNoTipsConst } from "../../component/gconst/TodayNoTipsConst";
import { CheckBoxWin } from "../view/common/alertwins/CheckBoxWin";
import { TItemWeapon } from "../../../Message/Db/Tables/TItemWeapon";
import { PetSkillViewWindow } from "../view/pet/skillList/PetSkillViewWindow";
import { SPetModelList } from "../../../Message/Game/SPetModelList";
import { SAttributeUpdate } from "../../../Message/Public/SAttributeUpdate";
import { UpdateCode } from "../../component/gconst/UpdateCode";
import { PetRebornVo } from "../view/pet/vo/PetRebornVo";
import { PetBloodVesselVo } from "../view/pet/vo/PetBloodVesselVo";
type int = number;
//class PetController
    
    export  class PetController extends Controller
    {
        constructor()
        {
            
            super();Dispatcher.addEventListener(EventName.PetOpenWindow, this.onPetOpenWindowHandler);
            Dispatcher.addEventListener(EventName.PetBattle, this.onPetBattle);
            Dispatcher.addEventListener(EventName.PetBattleByUid, this.onPetBattleByUid);
            Dispatcher.addEventListener(EventName.PetAutoCall, this.onPetAutoCallHandler);
            Dispatcher.addEventListener(EventName.PetRest, this.onPetRest);
            Dispatcher.addEventListener(EventName.PetRelease, this.onPetRelease);
            Dispatcher.addEventListener(EventName.PetStatusChange, this.onPetStatusChange);
            Dispatcher.addEventListener(EventName.PetModify, this.onPetModify);
            Dispatcher.addEventListener(EventName.PetModifySuccess, this.onPetModifySuccess);
            Dispatcher.addEventListener(EventName.PetBattleSuccess, this.onPetBattleSuccessHandler);
            Dispatcher.addEventListener(EventName.PetRestSuccess, this.onPetRestSuccessHandler);
            Dispatcher.addEventListener(EventName.PetDeath, this.onPetDeathHandler);
            Dispatcher.addEventListener(EventName.PetStatusUpdate, this.onPetStatusUpdateHandler);
            Dispatcher.addEventListener(PetEventName.PetFeedClick, this.onFeedClickHandler);
            Dispatcher.addEventListener(GModuleEvent.PetAutoFeedPet, this.onAutoFeedPetHandler);
            Dispatcher.addEventListener(PetEventName.PetShowToTab, this.onPetShowToTabHandler);
            Dispatcher.addEventListener(EventName.Guide_PetCall, this.onGuidePetCall);
            Dispatcher.addEventListener(EventName.Guide_PetRefresh, this.onGuidePetRefresh);
            Dispatcher.addEventListener(EventName.Guide_PetMerge, this.onGuidePetMerge);
            Dispatcher.addEventListener(EventName.PetBagCapacityChange, this.onPetBagCapacityChange);
            Dispatcher.addEventListener(EventName.PetFeedInPack, this.onPetFeedInPackHandler);
            Dispatcher.addEventListener(EventName.PetViewInfo, this.onPetViewInfoHandler);
            Dispatcher.addEventListener(EventName.PetMeetLookOverPlayerPet, this.onPetMeetLookOverPlayerPetHandler);
            Dispatcher.addEventListener(EventName.PetShowInfo, this.onPetShowInfoHandler);
            Dispatcher.addEventListener(EventName.PetBagUpdate, this.onPetBagUpdateHandler);
            Dispatcher.addEventListener(EventName.PetStrengThenCant, this.onPetStrengThenCantHandler);
            Dispatcher.addEventListener(EventName.PetLearnSkill, this.onPetLearnSkillHandler);
            Dispatcher.addEventListener(EventName.PetLearnSkillSuccess, this.onPetLearnSkillSuccessHandler);
            Dispatcher.addEventListener(EventName.PetUpdateSkill, this.onPetUpdateSkillHandler);
            Dispatcher.addEventListener(EventName.PetUpdateSkillSuccess, this.onPetUpdateSkillSuccessHandler);
            Dispatcher.addEventListener(EventName.PetSkillOpenRefreshWindow, this.onPetSkillOpenRefreshWindowHandler);
            Dispatcher.addEventListener(PetEventName.PetBatchRefreshWindow, this.onPetBatchRefreshWindowHandler);
            Dispatcher.addEventListener(EventName.PetGetSkillProp, this.onPetGetSkillPropHandler);
            Dispatcher.addEventListener(EventName.PetGetSkillPropSuccess, this.onPetGetSkillPropSuccessHandler);
            Dispatcher.addEventListener(EventName.PetRandSkillProp, this.onPetRandSkillPropHandler);
            Dispatcher.addEventListener(EventName.PetRandSkillPropSuccess, this.onPetRandSkillPropSuccessHandler);
            Dispatcher.addEventListener(EventName.PetMakeSkillProp, this.onPetMakeSkillPropHandler);
            Dispatcher.addEventListener(EventName.PetMakeSkillPropSuccess, this.onPetMakeSkillPropSuccessHandler);
            Dispatcher.addEventListener(PetEventName.PetOpenForgetSkillWindow, this.onPetOpenForgetSkillWindowHandler);
            Dispatcher.addEventListener(EventName.PetForgetSkill, this.onPetForgetSkillHandler);
            Dispatcher.addEventListener(EventName.PetForgetSkillSuccess, this.onPetForgetSkillSuccessHandler);
            Dispatcher.addEventListener(EventName.PetDigSkill, this.onPetDigSkillHandler);
            Dispatcher.addEventListener(EventName.PetDigSkillSuccess, this.onPetDigSkillSuccessHandler);
            Dispatcher.addEventListener(EventName.PetChangePetModel, this.onPetChangePetModelHandler);
            Dispatcher.addEventListener(EventName.PetChangePetModelSuccess, this.onPetChangePetModelSuccessHandler);
            Dispatcher.addEventListener(EventName.PetRecoverModel, this.onPetRecoverModelHandler);
            Dispatcher.addEventListener(EventName.PetOpenSkillStudyTab, this.onPetOpenSkillStudyTabHandler);
            Dispatcher.addEventListener(EventName.PetEatEgg, this.onPetEatEggHandler);
            Dispatcher.addEventListener(EventName.PetLifespanAdd, this.onPetLifespanAddHandler);
            Dispatcher.addEventListener(EventName.PetExtend, this.onPetExtendHandler);
            Dispatcher.addEventListener(EventName.PetExtendPreview, this.onPetExtendPreviewHandler);
            Dispatcher.addEventListener(EventName.PetAddBless, this.onPetAddBlessHandler);
            Dispatcher.addEventListener(EventName.PetAddBlessSuccess, this.onPetAddBlessSuccessHandler);
            Dispatcher.addEventListener(EventName.PetXisui, this.onPetXisuiHandler);
            Dispatcher.addEventListener(EventName.PetXisuiSuccess, this.onPetXisuiSuccessHandler);
            Dispatcher.addEventListener(EventName.PetXisuiOpen, this.onPetXisuiOpenHandler);
            Dispatcher.addEventListener(EventName.PetChangeUpgradeModel, this.onPetChangeUpgradeModelHandler);
            Dispatcher.addEventListener(EventName.PetSkillHelpWindowOpen, this.onPetSkillHelpWindowOpenHandler);
            Dispatcher.addEventListener(EventName.PetLifespanWindowOpen, this.onPetLifespanWindowOpenHandler);
            Dispatcher.addEventListener(EventName.Guide_PetSkillRefreshOpenSkill, this.onGuideOpenSkillHandler);
            Dispatcher.addEventListener(EventName.Guide_PetSkillRefreshUseItem, this.onGuideUseItemRefreshSkillHandler);
            Dispatcher.addEventListener(EventName.Guide_PetSkillRefreshOpt, this.onGuideRefreshSkillOptHandler);
            Dispatcher.addEventListener(EventName.Guide_PetSkillRefreshOpt2, this.onGuideRefreshSkillOptHandler2);
            Dispatcher.addEventListener(EventName.Guide_PetSkillCallOpt, this.onGuideCallSkillOptHandler);
            Dispatcher.addEventListener(EventName.PetSkillSeal, this.onPetSkillSealHandler);
            Dispatcher.addEventListener(EventName.PetSkillUnseal, this.onPetSkillUnsealHandler);
            Dispatcher.addEventListener(EventName.PetSkillTidy, this.onPetSkillTidyHandler);
            Dispatcher.addEventListener(EventName.PetEquipsBagShowOrHide, this.onShowPetEquipBag);
            Dispatcher.addEventListener(EventName.PetEquipDress, this.onDressPetEquip);
            Dispatcher.addEventListener(EventName.PetEquipUndress, this.onUndressPetEquip);
            Dispatcher.addEventListener(EventName.PetEquipUndressAll, this.onUndressAllPetEquips);
            Dispatcher.addEventListener(EventName.PetEquipRepairAll, this.onRepairAllEquips);
            Dispatcher.addEventListener(EventName.PetEquipGetAllRepairCost, this.onGetAllRepairCost);
            NetDispatcher.addCmdListener(ServerCommand.PetEquipItemInfoChange, this.onPetEquipItemInfoChange);
            NetDispatcher.addCmdListener(ServerCommand.BackPackItemsChange, this.onBackPackItemChange);
            Dispatcher.addEventListener(EventName.PetSkillViewWindowOpen, this.onPetSkillViewWindowOpenHandler);
            Dispatcher.addEventListener(EventName.Guide_PetLifeDressOpen, this.onGuidePetLifeDressOpenHandler);
            Dispatcher.addEventListener(EventName.PetChangeModelGetList, this.onPetChangeModelGetListHandler);
            Dispatcher.addEventListener(EventName.PetChangeModel, this.onPetChangeModelHandler);
            Dispatcher.addEventListener(EventName.PetActivateModel, this.onPetActivateModelHandler);
            Dispatcher.addEventListener(EventName.LoginGameSuccess, this.onPetChangeModelGetListHandler);
            Dispatcher.addEventListener(EventName.PetCallBackAlert, this.onPetCallBackAlertHandler);
            Dispatcher.addEventListener(EventName.PetReborn, this.onPetRebornHandler);
            Dispatcher.addEventListener(EventName.PetRebornSuccess, this.onPetRebornSuccessHandler);
            Dispatcher.addEventListener(EventName.PetRebornShowReq, this.onPetRebornShowReqHandler);
            Dispatcher.addEventListener(EventName.PetRebornShowReqSuccess, this.onPetRebornShowReqSuccessHandler);
            Dispatcher.addEventListener(EventName.PetSkillUpgrade, this.onPetSkillUpgradeHandler);
            Dispatcher.addEventListener(EventName.PetSkillUpgradeSucess, this.onPetSkillUpgradeSucessHandler);
            Dispatcher.addEventListener(EventName.PetSkillUse, this.onPetSkillUseHandler);
            Dispatcher.addEventListener(EventName.PetSkillActivate, this.onPetSkillActivateHandler);
            Dispatcher.addEventListener(EventName.PetSpecailSkillInfoGet, this.onPetSpecailSkillInfoGetHandler);
            NetDispatcher.addCmdListener(EGateCommand._ECmdGatePetSpecialSkillInfo, this.onPetSpecialSkillInfoHandler);
            Dispatcher.addEventListener(EventName.PetBloodUpgradeReq, this.onPetBloodUpgradeReqHandler);
            Dispatcher.addEventListener(EventName.PetBloodInfoReq, this.onPetBloodInfoReqHandler);
            Dispatcher.addEventListener(EventName.PetBloodInfoRes, this.onPetBloodInfoResHandler);
            Dispatcher.addEventListener(EventName.PetBloodUpgradeResult, this.onPetBloodUpgradeResultHandler);
            return;
        }

        /* internal  */onPetBloodInfoResHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as SPetBlood;
            if (this._petModule && !this._petModule.isHide) 
            {
                this._petModule.petBloodInfoRes(loc1);
            }
            return;
        }

        /* internal  */onPetBloodUpgradeResultHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data.isSucceed as Boolean;
            var loc2=arg1.data.vo as SPetBlood;
            if (this._petModule && !this._petModule.isHide) 
            {
                this._petModule.petBloodUpgradeResult(loc1, loc2);
            }
            return;
        }

        /* internal  */onPetSkillUseHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as PetSkillUpgradeOperateVo;
            GameProxy.petProxy.usePetSpecailSkill(loc1);
            return;
        }

        /* internal  */onPetSkillActivateHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as PetSkillUpgradeOperateVo;
            GameProxy.petProxy.learnPetSpecailSkill(loc1);
            return;
        }

        /* internal  */onPetSpecailSkillInfoGetHandler(arg1: DataEvent): void
        {
            GameProxy.petProxy.getPetSpecailSkillInfo(arg1.data as string);
            return;
        }

        /* internal  */onPetSpecialSkillInfoHandler(arg1: MessageBlock): void
        {
            var loc1=arg1.messageBase as SPetSpecialSkillInfo;
            if (this._petModule && !this._petModule.isHide) 
            {
                this._petModule.petSpecialSkillInfo(loc1);
            }
            return;
        }

        /* internal  */onPetSkillUpgradeSucessHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data.expAdd as int;
            var loc2=arg1.data.critExpAdd as int;
            if (loc1 > 0 && this._petModule && !this._petModule.isHide) 
            {
                this._petModule.petSkillUpgradeSucess(loc1, false);
            }
            else if (loc2 > 0 && this._petModule && !this._petModule.isHide) 
            {
                this._petModule.petSkillUpgradeSucess(loc2, true);
            }
            return;
        }

        
        {
            PetController._isShowResumeTip = true;
            PetController.isBatchRefresh = false;
        }

        protected /* override */ initServer(): void
        {
            super.initServer();
            NetDispatcher.addCmdListener(ServerCommand.PetBagMsg, this.onPetBagGet);
            NetDispatcher.addCmdListener(ServerCommand.LookupPetReplySuccess, this.onLookupPetReplySuccess);
            NetDispatcher.addCmdListener(ServerCommand.PetHireDetailInfoCommand, this.onLookupPetReplySuccess);
            NetDispatcher.addCmdListener(ServerCommand.PetSkillFreeRandUpdate, this.onPetSkillFreeRandUpdateHandler);
            NetDispatcher.addCmdListener(ServerCommand.PetWarehouseSkillUpdate, this.onPetWarehouseSkillUpdateHandler);
            NetDispatcher.addCmdListener(ServerCommand.PetRandSkillActiveCommand, this.onPetRandSkillActiveCommandHandler);
            NetDispatcher.addCmdListener(ServerCommand.PetChangeModelListCommand, this.onPetChangeModelListCommandHandler);
            NetDispatcher.addCmdListener(ServerCommand.PetBlessValueCommand, this.onPetBlessValueCommandHandler);
            return;
        }

        protected /* override */ initView(): IView
        {
            if (null == this._petModule) 
            {
                this._petModule = new PetModule();
                this._petModule.addEventListener(WindowEvent.SHOW, this.onPetWindowShowHandler);
                this._petModule.addEventListener(WindowEvent.CLOSE, this.onPetWindowCloseHandler);
                this._petModule.addEventListener(EventName.PetTabBarChange, this.onTabBarChangeHandler);
            }
            return this._petModule;
        }

        public get petModule(): IPetModule
        {
            if (null == this._petModule) 
            {
                this.initView();
            }
            return this._petModule;
        }

        public /* override */ get view(): IView
        {
            return this.initView();
        }

        /* internal  */onPetWindowShowHandler(arg1: WindowEvent): void
        {
            this.petModule.initPetPanel(this.getHireSortArray(cache.pet.petInfos));
            if (!cache.guide.guidePetMerge) 
            {
                Dispatcher.dispatchEvent(new DataEvent(PetEventName.PetShowToTab, 0));
            }
            this.onGuidePetCall(null);
            this.onGuidePetRefresh(null);
            this.onGuidePetMerge(null);
            this.onGuidePetVersionChange();
            Dispatcher.dispatchEvent(new DataEvent(EventName.PetWindowShow));
            return;
        }

        /* internal  */onPetWindowCloseHandler(arg1: WindowEvent): void
        {
            if (cache.guide.petGuide || cache.guide.guidePetRefresh) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetWindowClose, this.petModule.currentPet));
            }
            else if (cache.guide.guidePetMerge) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetWindowClose, this.petModule.currentPet));
                if (!cache.pet.battlePet && cache.pet.petInfos.length > 0) 
                {
                    this.petBattle(cache.pet.petInfos[(cache.pet.petInfos.length - 1)]);
                }
            }
            else if (cache.guidePetSkillRefresh.needOpenSkillModule()) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetWindowClose, this.petModule.currentPet));
            }
            return;
        }

        /* internal  */getHireSortArray(arg1: Array<any>): Array<any>
        {
            var loc4=null;
            var loc1=[];
            var loc2=[];
            var loc3=[];
            var loc5=0;
            var loc6=arg1;
            for(loc4 of loc6) 
            {
                if (loc4.isBorrow) 
                {
                    loc1.push(loc4);
                    continue;
                }
                if (PetUtil.isBattled(loc4)) 
                {
                    loc2.push(loc4);
                    continue;
                }
                loc3.push(loc4);
            }
            loc1 = loc1.concat(loc2).concat(loc3);
            return loc1;
        }

        public onPetBagGet(arg1: SPetBag): void
        {
            var loc1=cache.pet.getBattlePet();
            if (null != loc1) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetBattleSuccess, {"uid": loc1.uid, "entityId": cache.pet.entityId}));
            }
            return;
        }

        public onPetBagUpdateHandler(arg1: DataEvent): void
        {
            var loc2=null;
            var loc1=arg1.data as SPetUpdate;
            if (loc1 && !(loc1.updateType == 4) && (loc1.bagType == EPlayerItemPosType._EPlayerItemPosTypePet || loc1.bagType == EPlayerItemPosType._EPlayerItemPosTypePetWarehouse)) 
            {
                loc2 = PetColor.getColorName(loc1.petInfo);
                if (loc1.updateType != 1) 
                {
                    if (loc1.updateType == 2) 
                    {
                        if (this.petModule && this.petModule.isHide == false || loc1.bagType == EPlayerItemPosType._EPlayerItemPosTypePetWarehouse) 
                        {
                            if (loc2 != "") 
                            {
                                MsgManager.showRollTipsMsg(Language.getStringByParam(54015, loc2));
                                MsgManager.addTipText(Language.getStringByParam(54015, loc2));
                            }
                        }
                    }
                }
                else if (loc2 != "") 
                {
                    MsgManager.showRollTipsMsg(Language.getStringByParam(54014, loc2));
                    MsgManager.addTipText(Language.getStringByParam(54014, loc2));
                    if (loc1.updateCode != 103) 
                    {
                        if (loc1.updateCode == 63) 
                        {
                            this.dealIlluByPetInfo(loc1.petInfo);
                        }
                    }
                    else 
                    {
                        PetAddWindow.instance.updateByPetInfo(loc1.petInfo);
                        PetAddWindow.instance.show();
                    }
                }
            }
            if (this._petModule && this._petModule.isHide == false) 
            {
                this.petModule.updatePet(loc1);
            }
            return;
        }

        /* internal  */dealIlluByPetInfo(arg1: SPetInfo): void
        {
            Dispatcher.dispatchEvent(new DataEvent(PetIlluEventName.DealGetNewPet, arg1));
            return;
        }

        /* internal  */onPetStatusChange(arg1: DataEvent): void
        {
            var loc1=arg1.data["uid"] as string;
            var loc2=new EPetStatus(arg1.data["status"] as int);
            GameProxy.petProxy.changePetStatus(loc1, loc2);
            return;
        }

        /* internal  */onPetOpenWindowHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as int;
            this.petModule.show();
            Dispatcher.dispatchEvent(new DataEvent(PetEventName.PetShowToTab, loc1));
            return;
        }

        /* internal  */onPetBattle(arg1: DataEvent): void
        {
            if (cache.copy.isInArenaCrossCopy() && !GameMapUtil.curMapState.isArenaCross) 
            {
                MsgManager.showRollTipsMsg(Language.getString(54622));
                return;
            }
            var loc1=arg1.data as SPetInfo;
            this.petBattle(loc1);
            return;
        }

        /* internal  */petBattle(arg1: SPetInfo): void
        {
            var petInfo: SPetInfo;

            var loc1;
            petInfo = arg1;
            if (petInfo.status == EPetStatus._EPetSire) 
            {
                MsgManager.showRollTipsMsg(Language.getString(54016));
                return;
            }
            if (petInfo.status == EPetStatus._EpetTrain) 
            {
                MsgManager.showRollTipsMsg(Language.getString(54017));
                return;
            }
            if (PetUtil.isBattled(petInfo)) 
            {
                MsgManager.showRollTipsMsg(Language.getString(54018));
                return;
            }
            if (petInfo.life == 0) 
            {
                MsgManager.showRollTipsMsg(Language.getString(54019));
                return;
            }
            if (petInfo.energy <= 0) 
            {
                MsgManager.showRollTipsMsg(Language.getString(54020));
                return;
            }
            ScreenOperation.interruptToCallPet((): void
            {
                GameProxy.petProxy.activatePet(petInfo.uid);
                return;
            })
            return;
        }

        /* internal  */onPetBattleByUid(arg1: DataEvent): void
        {
            var loc1=arg1.data as string;
            var loc2=cache.pet.getPetInfoByUid(loc1);
            if (loc2) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetBattle, loc2));
            }
            return;
        }

        /* internal  */onPetAutoCallHandler(arg1: DataEvent): void
        {
            var loc1=null;
            if (AutoFight.currentAutoFight.isAutoFight && AutoFight.currentAutoFight.callPet) 
            {
                loc1 = GameController.gameui.getGameui().getPetAvatarSPetInfo();
                if (loc1 && loc1.status == EPetStatus._EPetEquip) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.PetBattleByUid, loc1.uid));
                }
            }
            return;
        }

        /* internal  */onPetRest(arg1: DataEvent): void
        {
            var loc1=cache.pet.battlePet;
            if (loc1) 
            {
                if (Cache.instance.timeCdCache.isPetCoolDown(new PetCoolDownInfo(loc1.uid, 1))) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(54620));
                    return;
                }
                GameProxy.petProxy.deactivatePet(loc1.uid);
            }
            return;
        }

        /* internal  */onPetRelease(arg1: DataEvent): void
        {
            var loc1=arg1.data["uid"] as string;
            var loc2=arg1.data["posType"] as int;
            GameProxy.petProxy.firePet(loc1, loc2);
            return;
        }

        /* internal  */onPetModify(arg1: DataEvent): void
        {
            var loc1=arg1.data["uid"] as string;
            var loc2=arg1.data["petName"] as string;
            GameProxy.petProxy.changePetName(loc1, loc2);
            return;
        }

        /* internal  */onPetModifySuccess(arg1: DataEvent): void
        {
            MsgManager.showRollTipsMsg(Language.getString(54021));
            return;
        }

        /* internal  */onPetBattleSuccessHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["uid"] as string;
            cache.pet.battlePet = cache.pet.getPetInfoByUid(loc1);
            MsgManager.showRollTipsMsg(Language.getString(54022));
            SoundManager.instance.soundPlay(SoundTypeConst.GetPet);
            return;
        }

        /* internal  */onPetRestSuccessHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as string;
            cache.pet.battlePet = null;
            return;
        }

        /* internal  */onPetDeathHandler(arg1: DataEvent): void
        {
            cache.pet.battlePet = null;
            return;
        }

        /* internal  */onPetStatusUpdateHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as SPetStatusUpdate;
            if (this._petModule && this._petModule.isHide == false) 
            {
                this._petModule.updatePetStatus(loc1);
            }
            return;
        }

        /* internal  */onFeedClickHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["petInfo"] as SPetInfo;
            var loc2=arg1.data["feedType"] as string;
            var loc3;
            if (loc3 = cache.pack.backPackCache.getPetDrugItem(loc1, loc2)) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.FeedPet, {"itemData": loc3, "amount": 1, "petUid": loc1.uid}));
            }
            else if (loc2 != FeedType.Energy) 
            {
                if (loc2 != FeedType.Life) 
                {
                    if (loc2 != FeedType.Mana) 
                    {
                        if (loc2 == FeedType.LifeSpan) 
                        {
                            MsgManager.showRollTipsMsg(Language.getString(54026));
                        }
                    }
                    else 
                    {
                        MsgManager.showRollTipsMsg(Language.getString(54025));
                    }
                }
                else 
                {
                    MsgManager.showRollTipsMsg(Language.getString(54024));
                }
            }
            else 
            {
                MsgManager.showRollTipsMsg(Language.getString(54023));
            }
            return;
        }

        /* internal  */onAutoFeedPetHandler(arg1: DataEvent): void
        {
            var loc4=null;
            var loc5=null;
            var loc1=arg1.data["petInfo"] as SPetInfo;
            var loc2=arg1.data["feedType"] as string;
            var loc3;
            if ((loc3 = arg1.data["effectType"] as string) != PetDrugEffect.Duration) 
            {
                loc4 = cache.pack.backPackCache.getPetDrugItem(loc1, loc2);
            }
            else 
            {
                loc4 = cache.pack.backPackCache.getPetDrugItem(loc1, loc2);
            }
            if (loc4) 
            {
                loc5 = loc4.uid;
                Dispatcher.dispatchEvent(new DataEvent(EventName.FeedPet, {"itemData": loc4, "amount": 1, "petUid": loc1.uid}));
                PetController._isShowResumeTip = true;
            }
            else if (PetController._isShowResumeTip) 
            {
                MsgManager.showRollTipsMsg(Language.getString(54027));
                PetController._isShowResumeTip = false;
            }
            return;
        }

        /* internal  */onGuidePetCall(arg1: DataEvent): void
        {
            if (cache.guide.petGuide) 
            {
                this.petModule.guidePetCall();
            }
            return;
        }

        /* internal  */onGuidePetRefresh(arg1: DataEvent): void
        {
            if (cache.guide.guidePetRefresh) 
            {
                GuideArrowManager.hideGuideArrow();
                if (cache.pet.petInfos.length > 0) 
                {
                    this.petModule.guidePetRefresh();
                }
                else 
                {
                    this.getPetsAlert();
                }
            }
            return;
        }

        /* internal  */getPetsAlert(): void
        {
            Alert.buttonWidth = 100;
            Alert.showCloseBtn = true;
            Alert.okLabel = Language.getString(54028);
            Alert.calcelLabel = Language.getString(54029);
            Alert.show(Language.getString(54030), null, Alert.OK | Alert.CANCEL, null, this.onGuideRefreshAlert);
            return;
        }

        /* internal  */onGuideRefreshAlert(arg1: int): void
        {
            var loc1=null;
            cache.guide.guidePetRefresh = false;
            cache.guide.guidePetMerge = false;
            this.petModule.hide();
            if (arg1 != Alert.OK) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ShopMallShowToTab, ShopRule.ShopMallPet));
            }
            else 
            {
                loc1 = cache.scene.getNearlyNpcByCopyId(105);
                AIManager.onAutoPathAIControl(loc1);
            }
            return;
        }

        /* internal  */onPetStrengThenCantHandler(arg1: DataEvent): void
        {
            if (cache.guide.guidePetRefresh && this.petModule && !this.petModule.isHide) 
            {
                this.petModule.hide();
            }
            return;
        }

        /* internal  */onGuidePetMerge(arg1: DataEvent): void
        {
            if (cache.guide.guidePetMerge) 
            {
                if (cache.pet.petInfos.length > 0) 
                {
                    this.onPetRest(null);
                    this.petModule.guidePetMerge();
                }
                else 
                {
                    this.getPetsAlert();
                }
            }
            return;
        }

        /* internal  */onGuidePetVersionChange(): void
        {
            if (cache.guide.petVersionChange) 
            {
                this.petModule.guidePetVersionChange();
                cache.guide.petVersionChange = false;
            }
            return;
        }

        /* internal  */onPetBagCapacityChange(arg1: DataEvent): void
        {
            if (this.petModule) 
            {
                this.petModule.changePetCapacity();
            }
            return;
        }

        /* internal  */onPetFeedInPackHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["itemData"] as ItemData;
            var loc2=arg1.data["amount"] as int;
            var loc3=cache.pet.battlePet;
            if (loc1) 
            {
                if (loc3) 
                {
                    if (loc1.itemInfo.item.level > PetUtil.getFourDigitLevel(loc3.reinLevel, loc3.level)) 
                    {
                        MsgManager.showRollTipsMsg(Language.getString(54031));
                        return;
                    }
                    Dispatcher.dispatchEvent(new DataEvent(EventName.FeedPet, {"itemData": loc1, "amount": loc2, "petUid": loc3.uid}));
                }
                else 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.FeedPet, {"itemData": loc1, "amount": loc2}));
                }
            }
            return;
        }

        /* internal  */onPetViewInfoHandler(arg1: DataEvent): void
        {
            var loc1=cache.role.entityInfo.entityId;
            var loc2=arg1.data as SEntityId;
            GameProxy.playerInfoProxy.lookupRequest_async(loc1, loc2);
            return;
        }

        /* internal  */onPetMeetLookOverPlayerPetHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["playerId"] as int;
            var loc2=arg1.data["petUid"] as string;
            GameProxy.petProxy.lookOverPlayerPet(loc1, loc2);
            return;
        }

        /* internal  */onPetShowInfoHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as SPetInfo;
            this.onLookupPetReplySuccess(loc1);
            return;
        }

        /* internal  */onLookupPetReplySuccess(arg1: SPetInfo): void
        {
            if (arg1) 
            {
                if (this._petViewWindow == null) 
                {
                    this._petViewWindow = new PetViewWindow();
                }
                this._petViewWindow.updatePetInfoPanel(arg1);
                if (this.petModule && this.petModule.isHide == false) 
                {
                    this._petViewWindow.show(this.petModule.x + 30, this.petModule.y);
                }
                else 
                {
                    this._petViewWindow.show();
                }
            }
            return;
        }

        /* internal  */onPetLearnSkillHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["uid"] as string;
            var loc2=arg1.data["skillId"] as int;
            GameProxy.petProxy.learnSkill(loc1, loc2);
            return;
        }

        /* internal  */onPetLearnSkillSuccessHandler(arg1: DataEvent): void
        {
            MsgManager.showRollTipsMsg(Language.getString(54033));
            return;
        }

        /* internal  */onPetUpdateSkillHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["uid"] as string;
            var loc2=arg1.data["oldSkillId"] as int;
            GameProxy.petProxy.updateSkill(loc1, loc2);
            return;
        }

        /* internal  */onPetUpdateSkillSuccessHandler(arg1: DataEvent): void
        {
            MsgManager.showRollTipsMsg(Language.getString(54034));
            return;
        }

        /* internal  */onPetSkillOpenRefreshWindowHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as ItemData;
            if (this._petSkillRefreshWindow == null) 
            {
                this._petSkillRefreshWindow = new PetSkillRefreshWindow();
            }
            this._petSkillRefreshWindow.itemData = loc1;
            if (loc1.itemCode != Cache.instance.guidePetSkillRefresh.getGuideItemCode()) 
            {
                this._petSkillRefreshWindow.isCanFreeRand = cache.pet.freeLeftTimes > 0;
            }
            else 
            {
                this._petSkillRefreshWindow.isCanFreeRand = true;
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.PetGetSkillProp, loc1.uid));
            this._petSkillRefreshWindow.show();
            if (this._petSkillBatchRefreshWindow) 
            {
                this._petSkillBatchRefreshWindow.hide();
            }
            return;
        }

        /* internal  */onPetBatchRefreshWindowHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["itemData"] as ItemData;
            var loc2=arg1.data["skills"] as Array<any>;
            var loc3=arg1.data["allTimes"] as int;
            if (this._petSkillBatchRefreshWindow == null) 
            {
                this._petSkillBatchRefreshWindow = new BatchRefreshWindow();
            }
            this._petSkillBatchRefreshWindow.itemData = loc1;
            this._petSkillBatchRefreshWindow.skills = loc2;
            this._petSkillBatchRefreshWindow.allTimes = loc3;
            this._petSkillBatchRefreshWindow.show();
            if (this._petSkillRefreshWindow) 
            {
                this._petSkillRefreshWindow.hide();
            }
            return;
        }

        /* internal  */onPetGetSkillPropHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as string;
            GameProxy.petProxy.getPetSkillProp(loc1);
            return;
        }

        /* internal  */onPetGetSkillPropSuccessHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["skills"] as Array<any>;
            var loc2=arg1.data["allTimes"] as int;
            if (this._petSkillRefreshWindow) 
            {
                this._petSkillRefreshWindow.skills = loc1;
                this._petSkillRefreshWindow.allTimes = loc2;
            }
            return;
        }

        /* internal  */onPetRandSkillPropHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["uid"] as string;
            var loc2=arg1.data["unit"] as int;
            var loc3=arg1.data["times"] as int;
            GameProxy.petProxy.randPetSkillProp(loc1, loc2, loc3);
            return;
        }

        /* internal  */onPetRandSkillPropSuccessHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["skills"] as Array<any>;
            var loc2=arg1.data["allTimes"] as int;
            var loc3=arg1.data["times"] as int;
            if (PetController.isBatchRefresh) 
            {
                if (this._petSkillBatchRefreshWindow) 
                {
                    this._petSkillBatchRefreshWindow.skills = loc1;
                    this._petSkillBatchRefreshWindow.allTimes = loc2;
                }
            }
            else if (this._petSkillRefreshWindow) 
            {
                this._petSkillRefreshWindow.skills = loc1;
                this._petSkillRefreshWindow.allTimes = loc2;
            }
            var loc4=loc3 == 0;
            Dispatcher.dispatchEvent(new DataEvent(EventName.PetSkillRefressResult, loc4));
            return;
        }

        /* internal  */onPetMakeSkillPropHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["uid"] as string;
            var loc2=arg1.data["skillId"] as int;
            GameProxy.petProxy.makePetSkillProp(loc1, loc2);
            return;
        }

        /* internal  */onPetMakeSkillPropSuccessHandler(arg1: DataEvent): void
        {
            if (this._petSkillBatchRefreshWindow) 
            {
                this._petSkillBatchRefreshWindow.clear();
                this._petSkillBatchRefreshWindow.hide();
            }
            if (this._petSkillRefreshWindow) 
            {
                this._petSkillRefreshWindow.clear();
                this._petSkillRefreshWindow.hide();
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.PetSkillGetResult));
            return;
        }

        /* internal  */onPetOpenForgetSkillWindowHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["petInfo"] as SPetInfo;
            var loc2=arg1.data["skillInfo"] as SPetSkill;
            if (this._petSkillForgetWindow == null) 
            {
                this._petSkillForgetWindow = new PetSkillForgetWindow();
            }
            this._petSkillForgetWindow.updateWindow(loc1, loc2);
            this._petSkillForgetWindow.show();
            return;
        }

        /* internal  */onPetForgetSkillHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["uid"] as string;
            var loc2=arg1.data["skillId"] as int;
            GameProxy.petProxy.forgetPetSkill(loc1, loc2);
            return;
        }

        /* internal  */onPetForgetSkillSuccessHandler(arg1: DataEvent): void
        {
            if (this._petSkillForgetWindow) 
            {
                this._petSkillForgetWindow.hide();
            }
            MsgManager.showRollTipsMsg(Language.getString(54035));
            return;
        }

        /* internal  */onPetDigSkillHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["petUid"] as string;
            var loc2=arg1.data["uid"] as string;
            var loc3=arg1.data["skillId"] as int;
            GameProxy.petProxy.digPetSkill(loc1, loc2, loc3);
            return;
        }

        /* internal  */onPetDigSkillSuccessHandler(arg1: DataEvent): void
        {
            MsgManager.showRollTipsMsg(Language.getString(54036));
            return;
        }

        /* internal  */onPetChangePetModelHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["petMainUid"] as string;
            var loc2=arg1.data["petDeputyUid"] as string;
            var loc3=arg1.data["uid"] as string;
            var loc4=arg1.data["isDeputy"] as int;
            GameProxy.petProxy.changePetModel(loc1, loc2, loc3, loc4);
            return;
        }

        /* internal  */onPetChangePetModelSuccessHandler(arg1: DataEvent): void
        {
            MsgManager.showRollTipsMsg(Language.getString(54037));
            return;
        }

        /* internal  */onPetRecoverModelHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as string;
            GameProxy.petProxy.recoverPetModel(loc1);
            return;
        }

        /* internal  */onPetOpenSkillStudyTabHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as ItemData;
            this.petModule.show();
            this.petModule.gotoStudySkillPanel(loc1);
            return;
        }

        /* internal  */onPetEatEggHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["uid"] as string;
            var loc2=arg1.data["eggs"] as Array<any>;
            GameProxy.petProxy.eatPetEggs(loc1, loc2);
            return;
        }

        /* internal  */onPetLifespanAddHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["petUid"] as string;
            var loc2=arg1.data["drugUid"] as string;
            var loc3=arg1.data["drugNum"] as int;
            GameProxy.petProxy.eatLifeSpanDrug(loc1, loc2, loc3);
            return;
        }

        /* internal  */onPetExtendHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["petMainUid"] as string;
            var loc2=arg1.data["petDeputyUid"] as string;
            GameProxy.petProxy.petMerge(loc1, loc2);
            return;
        }

        /* internal  */onPetExtendPreviewHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["petMainUid"] as string;
            var loc2=arg1.data["petDeputyUid"] as string;
            GameProxy.petProxy.petMergePreview(loc1, loc2);
            return;
        }

        /* internal  */onPetAddBlessHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["uid"] as string;
            var loc2=arg1.data["materials"] as Array<any>;
            var loc3=arg1.data["isGrowth"] as Boolean;
            GameProxy.petProxy.addPetBless(loc1, loc2, loc3);
            return;
        }

        /* internal  */onPetAddBlessSuccessHandler(arg1: DataEvent): void
        {
            return;
        }

        /* internal  */onPetXisuiHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["uid"] as string;
            var loc2=arg1.data["type"] as int;
            GameProxy.petProxy.petXisui(loc1, loc2);
            return;
        }

        /* internal  */onPetXisuiSuccessHandler(arg1: DataEvent): void
        {
            MsgManager.showRollTipsMsg(Language.getString(54038));
            return;
        }

        /* internal  */onPetXisuiOpenHandler(arg1: DataEvent): void
        {
            this.petModule.show();
            if (this.sleepTimer == null) 
            {
                this.sleepTimer = new Object /* flash.utils.Timer */(100);
                this.sleepTimer.repeatCount = 1;
                this.sleepTimer.addEventListener(flash.events.TimerEvent.TIMER_COMPLETE, this.onSleepCompleteHandler);
            }
            this.sleepTimer.reset();
            this.sleepTimer.start();
            return;
        }

        /* internal  */onSleepCompleteHandler(arg1: Object /* flash.events.Event */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(PetEventName.PetBrainwashWindowOpen, {"petInfo": this._petModule.currentPet}));
            this.sleepTimer.stop();
            return;
        }

        /* internal  */onPetChangeUpgradeModelHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["petUid"] as string;
            var loc2=arg1.data["callBack"] as Function;
            GameProxy.petProxy.changePetUpgradeModel(loc1, loc2);
            return;
        }

        /* internal  */onPetSkillHelpWindowOpenHandler(arg1: DataEvent): void
        {
            if (this._petSkillHelpWindow == null) 
            {
                this._petSkillHelpWindow = new PetSkillHelpWindow();
            }
            this._petSkillHelpWindow.show();
            return;
        }

        /* internal  */onPetShowToTabHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as int;
            this.view.show();
            this.petModule.showToTab(loc1);
            return;
        }

        /* internal  */onPetLifespanWindowOpenHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as string;
            if (this._lifespanWindow == null) 
            {
                this._lifespanWindow = new PetLifespanWindow();
            }
            this._lifespanWindow.show();
            if (loc1 != null) 
            {
                this._lifespanWindow.selectByUid(loc1);
            }
            return;
        }

        /* internal  */onPetSkillFreeRandUpdateHandler(arg1: int): void
        {
            if (this._petSkillRefreshWindow && this._petSkillRefreshWindow.isHide == false) 
            {
                this._petSkillRefreshWindow.isCanFreeRand = cache.pet.freeLeftTimes > 0;
            }
            return;
        }

        /* internal  */onGuideOpenSkillHandler(arg1: DataEvent): void
        {
            if (this.petModule.currentSkillTab()) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetTabBarToSkill, true));
            }
            else 
            {
                this.petModule.guideOpenSkillPanel();
            }
            return;
        }

        /* internal  */onGuideUseItemRefreshSkillHandler(arg1: DataEvent): void
        {
            this.petModule.guideUseItemRefreshSkill();
            return;
        }

        /* internal  */onTabBarChangeHandler(arg1: DataEvent): void
        {
            if (this.petModule.currentSkillTab()) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetTabBarToSkill, true));
            }
            else 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetTabBarToSkill, false));
            }
            return;
        }

        /* internal  */onGuideRefreshSkillOptHandler(arg1: DataEvent): void
        {
            if (this._petSkillRefreshWindow && !this._petSkillRefreshWindow.isHide) 
            {
                this._petSkillRefreshWindow.guideRefreshSkill();
            }
            return;
        }

        /* internal  */onGuideRefreshSkillOptHandler2(arg1: DataEvent): void
        {
            if (this._petSkillRefreshWindow && !this._petSkillRefreshWindow.isHide) 
            {
                this._petSkillRefreshWindow.guideRefreshSkill2();
            }
            return;
        }

        /* internal  */onGuideCallSkillOptHandler(arg1: DataEvent): void
        {
            if (this._petSkillRefreshWindow && !this._petSkillRefreshWindow.isHide) 
            {
                this._petSkillRefreshWindow.guideCallSkill();
            }
            return;
        }

        /* internal  */onPetWarehouseSkillUpdateHandler(arg1: Map<any, any> /* flash.utils.Dictionary */): void
        {
            if (this._petModule) 
            {
                this._petModule.updateDigPanelSkillList(arg1);
            }
            return;
        }

        /* internal  */onPetRandSkillActiveCommandHandler(arg1: SRandPetSkillActive): void
        {
            if (this._petSkillBatchRefreshWindow && this._petSkillBatchRefreshWindow.isHide == false) 
            {
                this._petSkillBatchRefreshWindow.showActiveInfo(true, arg1);
            }
            return;
        }

        /* internal  */onPetSkillSealHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["petUid"] as string;
            var loc2=arg1.data["uid"] as string;
            var loc3=arg1.data["skillId"] as int;
            GameProxy.petProxy.sealPetSkill(loc1, loc2, loc3);
            return;
        }

        /* internal  */onPetSkillUnsealHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["petUid"] as string;
            var loc2=arg1.data["pos"] as int;
            GameProxy.petProxy.unsealPetSkill(loc1, loc2);
            return;
        }

        /* internal  */onPetSkillTidyHandler(arg1: DataEvent): void
        {
            GameProxy.petProxy.tidyPetSkills();
            return;
        }

        /* internal  */onShowPetEquipBag(arg1: DataEvent): void
        {
            if (this._petModule && !this._petModule.isHide) 
            {
                this._petModule.showOrHideEquipsBag();
            }
            return;
        }

        /* internal  */onDressPetEquip(arg1: DataEvent): void
        {
            if (this._petModule && this._petModule.isHide) 
            {
                this._petModule.show();
                this._petModule.showEquipsBag(true);
            }
            var loc1=arg1.data as ItemData;
            if (this._petModule && this._petModule.currentPet && !this._petModule.currentPet.isBorrow) 
            {
                if (PetUtil.getFourDigitLevel(this._petModule.currentPet.reinLevel, this._petModule.currentPet.level) < loc1.itemInfo.item.level) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(61335));
                    return;
                }
                if (ItemsUtil.isBind(loc1)) 
                {
                    this.onDressAlertHandler(Alert.OK, loc1);
                }
                else 
                {
                    Alert.extendObj = loc1;
                    Alert.show(Language.getString(61334), Language.getString(69900), Alert.OK | Alert.CANCEL, null, this.onDressAlertHandler);
                }
            }
            return;
        }

        /* internal  */onDressAlertHandler(arg1: int, arg2: ItemData): void
        {
            if (arg1 == Alert.OK) 
            {
                GameProxy.petEquip.dress(this._petModule.currentPet.uid, arg2.uid);
            }
            return;
        }

        /* internal  */onUndressPetEquip(arg1: DataEvent): void
        {
            if (this._petModule && this._petModule.currentPet && !this._petModule.currentPet.isBorrow) 
            {
                GameProxy.petEquip.undress(this._petModule.currentPet.uid, arg1.data.uid);
            }
            return;
        }

        /* internal  */onUndressAllPetEquips(arg1: DataEvent): void
        {
            if (this._petModule && this._petModule.currentPet && !this._petModule.currentPet.isBorrow) 
            {
                GameProxy.petEquip.undressAll(this._petModule.currentPet.uid);
            }
            return;
        }

        /* internal  */onRepairAllEquips(arg1: DataEvent): void
        {
            if (this._petModule && this._petModule.currentPet && !this._petModule.currentPet.isBorrow) 
            {
                GameProxy.petEquip.repairPetWeapon(EPetEquipRepairType.convert(EPetEquipRepairType._EPetEquipRepairTypeAll), this._petModule.currentPet.petId + EPlayerItemPosType._EPlayerItemPosTypePetEquipBase, "");
            }
            return;
        }

        /* internal  */onPetEquipItemInfoChange(arg1): void
        {
            if (this._petModule && !this._petModule.isHide) 
            {
                this._petModule.updatePetEquips();
            }
            if ((!this._petModule || this._petModule.isHide) && !PulseSharedObject.isTodayNotTips(TodayNoTipsConst.PetEquipDurableTodayNoTips) && this.isDurableLow()) 
            {
                Alert.alertWinRenderer = CheckBoxWin;
                Alert.buttonWidth = 75;
                Alert.okLabel = Language.getString(61342);
                Alert.show(Language.getString(61341), null, Alert.OK | Alert.CANCEL, null, this.onDurableRepair);
            }
            return;
        }

        /* internal  */onDurableRepair(arg1: int, arg2: Boolean): void
        {
            if (arg1 == Alert.OK) 
            {
                this.view.show();
                this._petModule.showEquipsBag(true);
            }
            if (arg2) 
            {
                PulseSharedObject.save(TodayNoTipsConst.PetEquipDurableTodayNoTips, true);
            }
            return;
        }

        /* internal  */isDurableLow(): Boolean
        {
            var loc2=0;
            var loc3=0;
            var loc4=null;
            var loc5=null;
            var loc1=cache.pet.battlePet;
            if (loc1) 
            {
                loc4 = Cache.instance.pack.petEquip.getPetEquipsByPetId(loc1.petId);
                var loc6=0;
                var loc7=loc4;
                for(loc5 of loc7) 
                {
                    if (!(loc5.itemExInfo && loc5.itemInfo && loc5.itemInfo.extend is TItemWeapon)) 
                    {
                        continue;
                    }
                    loc2 = loc5.itemExInfo.durable;
                    loc3 = (loc5.itemInfo.extend as TItemWeapon).durableUpper;
                    if (!(loc3 > 0 && loc2 / loc3 < 0.1)) 
                    {
                        continue;
                    }
                    return true;
                }
            }
            return false;
        }

        /* internal  */onBackPackItemChange(arg1): void
        {
            if (this._petModule && !this._petModule.isHide) 
            {
                this._petModule.updateBagPetEquips();
            }
            return;
        }

        /* internal  */onGetAllRepairCost(arg1: DataEvent): void
        {
            if (this._petModule && this._petModule.currentPet && !this._petModule.currentPet.isBorrow) 
            {
                GameProxy.petEquip.repairPetAllWeaponCost(this._petModule.currentPet.petId + EPlayerItemPosType._EPlayerItemPosTypePetEquipBase);
            }
            return;
        }

        /* internal  */onPetSkillViewWindowOpenHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["skillId"] as int;
            var loc2=arg1.data["petInfo"] as SPetInfo;
            if (this._skillViewWindow == null) 
            {
                this._skillViewWindow = new PetSkillViewWindow();
            }
            this._skillViewWindow.updateSkillInfo(loc1, loc2);
            this._skillViewWindow.show();
            return;
        }

        /* internal  */onGuidePetLifeDressOpenHandler(arg1: DataEvent): void
        {
            if (this._petModule && !this._petModule.isHide) 
            {
                this._petModule.guidePetLifeDressOpen();
            }
            return;
        }

        /* internal  */onPetChangeModelGetListHandler(arg1: DataEvent): void
        {
            GameProxy.petProxy.getPetModelList();
            return;
        }

        /* internal  */onPetChangeModelHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data["petUid"] as string;
            var loc2=arg1.data["petCode"] as int;
            GameProxy.petProxy.changePetModelEx(loc1, loc2);
            return;
        }

        /* internal  */onPetActivateModelHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data.code as int;
            var loc2=arg1.data.auto as Boolean;
            var loc3=arg1.data.bind as Boolean;
            GameProxy.petProxy.activatePetCollectAttr(loc1, loc2, loc3);
            return;
        }

        /* internal  */onPetChangeModelListCommandHandler(arg1: SPetModelList): void
        {
            if (this._petModule && !this._petModule.isHide) 
            {
                this._petModule.updateChangeModelList(arg1);
            }
            return;
        }

        /* internal  */onPetBlessValueCommandHandler(arg1: SAttributeUpdate): void
        {
            if (this._petModule && !this._petModule.isHide) 
            {
                this._petModule.showBlessValueAddEffect(arg1);
            }
            return;
        }

        /* internal  */onPetCallBackAlertHandler(arg1: DataEvent): void
        {
            var e: DataEvent;
            var innerCloseHandler: Function;

            var loc1;
            innerCloseHandler = null;
            e = arg1;
            innerCloseHandler = (arg1: int): void
            {
                if (arg1 == Alert.OK) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.PetRest));
                }
                return;
            }
            Alert.show(Language.getString(54922), null, Alert.OK | Alert.CANCEL, null, innerCloseHandler);
            return;
        }

        /* internal  */onSpecialActivityRewardShowMsg(arg1: DataEvent): void
        {
            var loc1=arg1.data.str as string;
            var loc2=arg1.data.code as int;
            if (loc2 == UpdateCode.EUpdateCodePetSkillRefreshActive) 
            {
                if (this._petSkillRefreshWindow && !this._petSkillRefreshWindow.isHide) 
                {
                    this._petSkillRefreshWindow.showMsg(loc1);
                }
                if (this._petSkillBatchRefreshWindow && !this._petSkillBatchRefreshWindow.isHide) 
                {
                    this._petSkillBatchRefreshWindow.showMsg(loc1);
                }
            }
            return;
        }

        /* internal  */onPetRebornHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as PetRebornVo;
            if (loc1) 
            {
                GameProxy.petProxy.petReincarnate(loc1);
            }
            return;
        }

        /* internal  */onPetRebornSuccessHandler(arg1: DataEvent): void
        {
            if (this._petModule && !this._petModule.isHide) 
            {
                this._petModule.petRebornSuccess();
            }
            return;
        }

        /* internal  */onPetRebornShowReqHandler(arg1: DataEvent): void
        {
            GameProxy.petProxy.getReincarnateAttributeShow(arg1.data as string);
            return;
        }

        /* internal  */onPetRebornShowReqSuccessHandler(arg1: DataEvent): void
        {
            if (this._petModule && !this._petModule.isHide) 
            {
                this._petModule.petRebornShowReqSuccess(arg1.data.beforePetInfo, arg1.data.afterPetInfo);
            }
            return;
        }

        /* internal  */onPetSkillUpgradeHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as PetSkillUpgradeOperateVo;
            GameProxy.petProxy.feedPetSpecailSkill(loc1);
            return;
        }

        /* internal  */onPetBloodUpgradeReqHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as PetBloodVesselVo;
            GameProxy.petProxy.upgradePetBlood(loc1);
            return;
        }

        /* internal  */onPetBloodInfoReqHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as string;
            GameProxy.petProxy.getPetBloodInfo(loc1);
            return;
        }

        private /* var */_petModule: IPetModule;

        private /* var */_petViewWindow: PetViewWindow;

        private /* var */_petSkillRefreshWindow: PetSkillRefreshWindow;

        private /* var */_petSkillBatchRefreshWindow: BatchRefreshWindow;

        private /* var */_petSkillForgetWindow: PetSkillForgetWindow;

        private /* var */_petSkillHelpWindow: PetSkillHelpWindow;

        private /* var */_lifespanWindow: PetLifespanWindow;

        private /* var */_skillViewWindow: PetSkillViewWindow;

        private static /* var */_isShowResumeTip: Boolean=true;

        public static /* var */isBatchRefresh: Boolean=false;

        private /* var */sleepTimer: Object /* flash.utils.Timer */;
    }
